package zju.cst.seckill.redis;

/**
 * @className: BasePrefix
 * @description:
 * @author: wbr
 * @date: 2019-07-28 23:28
 */
public abstract class BasePrefix implements KeyPrefix {

    private int expireSeconds;
    private String prefix;

    public BasePrefix(int expireSeconds,String prefix){
        this.expireSeconds = expireSeconds;
        this.prefix = prefix;
    }
    public BasePrefix(String prefix) {
        this(0, prefix);
    }
    //过期时间，默认0代表永不过期
    @Override
    public int expireSeconds() {
        return expireSeconds;
    }

    @Override
    public String getPrefix() {
        String name = getClass().getSimpleName();
        return name+":"+prefix;
    }
}
